#pragma strict

var loopTime:float = 5;
private var au:AudioSource;

private var isPlaying:boolean;

function Start () {
	au = audio;
	// au.Stop();
	// au.time = 60;
	// au.Play();
}

function Update () {
	if(!au.isPlaying && !isPlaying){
		Play();
	}
	// Debug.Log(au.time +":" +au.clip.length +":"+au.isPlaying);
}

private function Play(){
	isPlaying = true;
	yield WaitForSeconds(loopTime);
	
	au.time = 0;
	au.Play();
	yield WaitForSeconds(au.clip.length);
	isPlaying = false;
}